FROM gauss-openeuler-os:22.03
ARG GAUSS_VERSION

ENV GAUSSHOME=/opt/openGauss
ENV GAUSSDATA=/opt/data 

#OpenGauss Version Information in env
ENV LANG=en_US.utf8
ENV GAUSS_VERSION=${GAUSS_VERSION}


# USER omm has been created in OS dockerfile image
RUN set -eux; \
    mkdir -p ${GAUSSHOME} && \
    mkdir -p ${GAUSSDATA} && \
    chmod -R 755 ${GAUSSDATA} && \
    mkdir /home/omm/.ssh && \ 
    chmod 700 /home/omm/.ssh && \
    chown -R omm:omm ${GAUSSDATA} /home/omm/.ssh 

#RUN gs_cgroup -U omm -H ${OPENGAUSS_ROOT_DIR} -c

ADD opengauss-${GAUSS_VERSION} ${GAUSSHOME}
ADD entrypoint.sh /

# Revise permission
RUN set -eux; \
    cd ${GAUSSHOME}; chmod -R +rx bin lib share dependency upgrade_sql *.sh && \ 
    chmod -R +r etc version.cfg opengauss_lite.conf share  && \
    chmod  -x bin/*.conf

USER omm